import type { RouteRecordRaw } from 'vue-router'

import { previewRoute } from '../preview/route'
import { uploadRoute } from '../upload/route'
import { Role } from '@/constants/role'
import { LabID } from '@/constants/lab'

export const enum ExperimentRouteName {
  MIMODebugger = 'MIMODebugger',
  MIMOPreview = 'MIMOPreview',
  MIMOSimulator = 'MIMOSimulator',
  MIMOUpload = 'MIMOUpload'
}

export const ExperimentRouteMap = {
  [LabID.MIMOSimulator]: ExperimentRouteName.MIMOSimulator,
  [LabID.LabPreview]: ExperimentRouteName.MIMOPreview,
  [LabID.MIMODebugger]: ExperimentRouteName.MIMODebugger,
  [LabID.ReportUpload]: ExperimentRouteName.MIMOUpload
}

export const MIMORoute = {
  path: 'mimo',
  children: [
    {
      path: 'debugger',
      name: ExperimentRouteName.MIMODebugger,
      meta: {
        requireAuth: true,
        role: Role.Student,
        menuTitle: 'navigation.experiment.mimo.debugger'
      },
      component: () => import('./ModuleDebugger/index.vue')
    },
    {
      path: 'simulator',
      name: ExperimentRouteName.MIMOSimulator,
      meta: {
        requireAuth: true,
        role: Role.Student,
        menuTitle: 'navigation.experiment.mimo.simulator'
      },
      component: () => import('./Simulator/index.vue')
    },
    {
      ...previewRoute,
      path: 'preview',
      children: [
        {
          path: '',
          name: ExperimentRouteName.MIMOPreview,
          meta: {
            requireAuth: true,
            role: Role.Student,
            menuTitle: 'navigation.experiment.mimo.preview'
          },
          component: () => import('./preview.md')
        }
      ]
    },
    {
      ...uploadRoute,
      path: 'upload',
      children: [
        {
          path: 'mimo',
          name: ExperimentRouteName.MIMOUpload,
          meta: {
            requireAuth: true,
            role: Role.Student,
            menuTitle: 'navigation.experiment.mimo.upload'
          },
          component: () => import('./report.md')
        }
      ]
    }
  ]
} as const satisfies RouteRecordRaw
